﻿package independence.testing.persistence 
{
	import asunit.framework.AsynchronousTestCase;
	import com.carlcalderon.arthropod.Debug;
	import flash.events.NetStatusEvent;
	import flash.net.NetConnection;
	import flash.net.Responder;
	import independence.testing.ITest;
	
	/**
	 * ...
	 * @author DefaultUser (Tools -> Custom Arguments...)
	 */
	public class HibernatePersistenceTestRunner implements ITest
	{
		private var connection:NetConnection;
		
		public function HibernatePersistenceTestRunner() 
		{
			this.connection = new NetConnection();
			this.connection.addEventListener(NetStatusEvent.NET_STATUS, netStatusListener, false, 0, true);
			this.connection.connect("rtmp://localhost/independence");
		}
		
		public function run():void
		{
			this.connection.call("independence.testing.hibernate.HibernatePersistenceTestRunner.persistNew", new Responder(onResultSuccess, onResultFault));
		}
		
		protected function netStatusListener(e:NetStatusEvent):void
		{
			Debug.log("HibernatePersistenceTestRunner - NetConnection Status: " + e.info.code);
		}
		
		protected function onResultSuccess(r:Object):void
		{
			Debug.log("HibernatePersistenceTestRunner - Operation success!", Debug.GREEN);
		}
		
		protected function onResultFault(r:Object):void
		{
			Debug.error("HibernatePersistenceTestRunner - Operation failure:");
			Debug.object(r);
		}
	}
	
}